﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.ServiceModel;
using SPVisualDev.Services;

namespace SPVisualDevWinSvc
{
    public partial class SPVisualDevService : ServiceBase
    {
        public ServiceHost serviceHost = null;

        public static void Main()
        {
            ServiceBase.Run(new SPVisualDevService());
        }

        // Start the Windows service.
        protected override void OnStart(string[] args)
        {
            //System.Diagnostics.Debugger.Break();

            if (serviceHost != null)
            {
                serviceHost.Close();
            }


            // Create a ServiceHost for the CalculatorService type and 
            // provide the base address.
            serviceHost = new ServiceHost(typeof(MainService));


            // Open the ServiceHostBase to create listeners and start 
            // listening for messages.
            serviceHost.Open();

        }

        // Stop the Windows service.
        protected override void OnStop()
        {
            if (serviceHost != null)
            {
                serviceHost.Close();
                serviceHost = null;
            }
        }

    }
}
